package com.gjw.designpattern.factory.factoryMethod;

/**
 * @Author gjw
 * 工厂方法模式
 * 工厂方法克服了简单工厂的缺点，增加新的产品时，不必修改现存的代码，而只需增加新代码。满足开放封闭原则。
 */
public class Client {
    public static void main(String[] args) {
        IPhoneFactory factory = new HuaWeiFactory();
        IPhoneFactory factory1 = new SanXingFactory();
        SanXingPhone sx = (SanXingPhone) factory1.getPhone();
        HuaWeiPhone hw = (HuaWeiPhone) factory.getPhone();

        System.out.println(hw.getName()+"是"+hw.getColor()+"的");
        System.out.println(sx.getName()+"是"+sx.getColor()+"的");
    }
}
